var selectBoj = $('select.navi-select');
//$('[type=submit]').buttonMarkup({ inline: "true" });

var search = new SearchResult("mysearch","search");

function initilizeSearch(text, next_page) {
	var param = {q : text}
	if(next_page != null){
		param = next_page;
	}
	$.mobile.showPageLoadingMsg();
	api.search(param, function(data) {
		$.mobile.hidePageLoadingMsg();
		for(i in data.results) {
			search.append(data.results[i]);
		}
			//アカウントページのイベント
		$("div#search div.tweet_unit img").click(accountShowEvent);
		//個々のツイートページのイベント
		$("div#search div.tweet_unit .tweet").click(tweetShowEvent);
		
		if(data.next_page != null){
			search.appendNextTweet();
			var next_page = data.next_page.replace("?","");
			$('#mysearch div:last').click(function(){
				$(this).remove();
				initilizeSearch("",next_page);
			});
		}
	});
}

$(document).bind("mobileinit", function(){
	$("#search-tweet").submit(function(){
		search.empty();
		var text = $("#search-tweet-text").val();
		initilizeSearch(text);
		return false;
	});
});